<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" version="1.0">
    
    <!-- == FO parameters == -->
        
    <xsl:param name="glossterm.width.auto">1</xsl:param>
    <!-- if non-zero, then maxtermlength will be set by template -->

    <xsl:param name="nongraphical.admonition.as.list-item" select="false()" />
    <!-- calls another template for alternate display -->

    <xsl:param name="admonition.as.coloured-block" select="true()" />
    <!-- colored block are alternate templates based on Apache styles -->
    
    <xsl:param name="deco.font.family" select="concat('Eurostile, Euromode,',$title.font.family)" />
    <!-- the decoration font family is used in covers, headers, footers.
    It is meant to look modern, thus Eurostile.
    Unfortunately this kind of fontface is not free and not available to anyone,
    so switch back to $title.font.family if no modern fontface is available.-->
    
    <xsl:param name="filename.hyphenates">1</xsl:param>
    <!-- same behavior as link.hyphenate, but for file and directory names. Needs more work. -->
    
    <xsl:param name="use.local.graphics.path" select="false()"/>
    <!-- basically used to test stylesheets locally -->
    
    <xsl:param name="xref.font.color" select="$title.font.color" />

    <xsl:param name="xref.title.as.string">1</xsl:param>
    <!-- not used yet. project is to remove all tags from titles before applying templates.
    This to avoid DBXSL original title styling in TOCs and other xrefs -->

    <!-- == FO properties == -->
    
    <xsl:attribute-set name="filename.properties">
        <xsl:attribute name="wrap-option">wrap</xsl:attribute>
        <xsl:attribute name="hyphenate">true</xsl:attribute>
        <xsl:attribute name="hyphenation-character">&#x200B;</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="admonition.as.coloured-block.properties">
    <!-- colored block are alternate templates based on Apache styles -->
        <xsl:attribute name="margin-left">0pt</xsl:attribute>
        <xsl:attribute name="margin-right">0pt</xsl:attribute>
        <xsl:attribute name="border-style">none</xsl:attribute>
        <xsl:attribute name="border-width">0pt</xsl:attribute>
        <xsl:attribute name="background-color">
            <xsl:choose>
                <xsl:when test="self::note|self::tip">#F0F0FF</xsl:when>
                <xsl:when test="self::warning|self::caution">#FFF0F0</xsl:when>
                <xsl:when test="self::important">#F0F0F0</xsl:when>
            </xsl:choose>
        </xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="admonition.as.coloured-block.title.properties">
    <!-- colored block are alternate templates based on Apache styles -->
        <xsl:attribute name="color">white</xsl:attribute>
        <xsl:attribute name="font-weight">bold</xsl:attribute>
        <xsl:attribute name="border-bottom-width">thin</xsl:attribute>
        <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
        <xsl:attribute name="border-bottom-color">
            <xsl:choose>
                <xsl:when test="self::note|self::tip">#006699</xsl:when>
                <xsl:when test="self::warning|self::caution">#990000</xsl:when>
                <xsl:when test="self::important">#000000</xsl:when>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="background-color">
            <xsl:choose>
                <xsl:when test="self::note|self::tip">#369</xsl:when>
                <xsl:when test="self::warning|self::caution">#C00</xsl:when>
                <xsl:when test="self::important">#000000</xsl:when>
            </xsl:choose>
        </xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="block-with-border.properties">
        <xsl:attribute name="border-color">#000000</xsl:attribute>
        <xsl:attribute name="border-style">solid</xsl:attribute>
        <xsl:attribute name="border-width">1px</xsl:attribute>
        <xsl:attribute name="padding">0.5em</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="compact.para.spacing">
    <!-- alternative to normal.para.spacing -->
        <xsl:attribute name="space-before.optimum">0.3em</xsl:attribute>
        <xsl:attribute name="space-before.minimum">0.2em</xsl:attribute>
        <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
        <xsl:attribute name="text-align-last">start</xsl:attribute>
        <xsl:attribute name="text-indent">0em</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="formal.object.body.properties">
        <xsl:attribute name="border-start-style">
            <xsl:choose>
                <xsl:when test="self::example">solid</xsl:when>
                <xsl:otherwise>none</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="border-start-color">
            <xsl:value-of select="$title.font.color" />
        </xsl:attribute>
        <xsl:attribute name="border-start-width">
            <xsl:choose>
                <xsl:when test="self::example">1pt</xsl:when>
                <xsl:otherwise>0pt</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="padding-start">
            <xsl:choose>
                <xsl:when test="self::example">1em</xsl:when>
                <xsl:otherwise>0em</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="margin-left">
            <xsl:choose>
                <xsl:when test="self::example">0.5em</xsl:when>
                <xsl:otherwise>0em</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="formal.title.label.properties">
        <xsl:attribute name="font-weight">bold</xsl:attribute>
        <xsl:attribute name="font-style">normal</xsl:attribute>
        <xsl:attribute name="hyphenate">false</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="guibutton.properties">
        <xsl:attribute name="font-family">
            <xsl:value-of select="$sans.font.family" />
        </xsl:attribute>
        <xsl:attribute name="font-size">0.8em</xsl:attribute>
        <xsl:attribute name="line-height">0.8em</xsl:attribute>
        <xsl:attribute name="baseline-shift">0.2em</xsl:attribute>
        <xsl:attribute name="padding-top">0.2em</xsl:attribute>
        <xsl:attribute name="padding-bottom">0.1em</xsl:attribute>
        <xsl:attribute name="padding-left">1em</xsl:attribute>
        <xsl:attribute name="padding-right">1em</xsl:attribute>
        <xsl:attribute name="border-width">medium</xsl:attribute>
        <xsl:attribute name="border-style">outset</xsl:attribute>
        <xsl:attribute name="border-color">#dddddd</xsl:attribute>
        <xsl:attribute name="background-color">#dddddd</xsl:attribute>
        <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="informal.object.body.properties">
        <xsl:attribute name="border-start-style">
            <xsl:choose>
                <xsl:when test="self::informalexample">solid</xsl:when>
                <xsl:otherwise>none</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="border-start-color">
            <xsl:value-of select="$title.font.color" />
        </xsl:attribute>
        <xsl:attribute name="border-start-width">
            <xsl:choose>
                <xsl:when test="self::informalexample">1pt</xsl:when>
                <xsl:otherwise>0pt</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="padding-start">
            <xsl:choose>
                <xsl:when test="self::informalexample">1em</xsl:when>
                <xsl:otherwise>0em</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:attribute name="margin-left">
            <xsl:choose>
                <xsl:when test="self::informalexample">0.5em</xsl:when>
                <xsl:otherwise>0em</xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="inline.charset.sans-serif.properties">   
        <xsl:attribute name="font-family">
            <xsl:value-of select="$sans.font.family"/>
        </xsl:attribute>     
        <xsl:attribute name="font-size">0.9em</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="nongraphical.admonition.as.blocks.properties">
        <xsl:attribute name="border-width">thin</xsl:attribute>
        <xsl:attribute name="border-style">solid</xsl:attribute>
        <xsl:attribute name="border-color">
            <xsl:choose>
                <xsl:when test="self::note|self::tip">#006699</xsl:when>
                <xsl:when test="self::warning|self::caution">#990000</xsl:when>
                <xsl:when test="self::important">#000000</xsl:when>
            </xsl:choose>
        </xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="rule.before.title.properties">
        <xsl:attribute name="border-top-style">solid</xsl:attribute>
        <xsl:attribute name="border-top-width">thin</xsl:attribute>
        <xsl:attribute name="border-top-color">
            <xsl:value-of select="$title.font.color" />
        </xsl:attribute>
        <xsl:attribute name="padding-top">4pt</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="rule.after.title.properties">
        <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
        <xsl:attribute name="border-bottom-width">thin</xsl:attribute>
        <xsl:attribute name="border-bottom-color">
            <xsl:value-of select="$title.font.color" />
        </xsl:attribute>
        <xsl:attribute name="padding-bottom">2pt</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="step.label.properties">
        <xsl:attribute name="color">
            <xsl:value-of select="$title.font.color" />
        </xsl:attribute>
        <xsl:attribute name="font-weight">bold</xsl:attribute>
    </xsl:attribute-set>

    <xsl:attribute-set name="term.properties">
        <xsl:attribute name="text-align">start</xsl:attribute>
        <xsl:attribute name="text-align-last">start</xsl:attribute>
        <xsl:attribute name="font-family">
            <xsl:choose>
                <xsl:when
                    test="ancestor::glosslist/@role = 'parameters' or ancestor::variablelist/@role = 'parameters'">
                    <xsl:value-of select="$monospace.font.family" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$body.font.family" />
                </xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    </xsl:attribute-set>

</xsl:stylesheet>
